package com.heima.wemedia.controller.v1;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.heima.model.common.dtos.AdSensitiveDto;
import com.heima.model.common.dtos.ResponseResult;

import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.common.pojos.wemedia.WmSensitive;
import com.heima.wemedia.mapper.WmSensitiveMapper;
import com.heima.wemedia.service.AdSensitiveService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@RestController
@RequestMapping("/api/v1/sensitive")
@Slf4j
public class AdSensitiveController {
    @Autowired
    private AdSensitiveService adSensitiveService;

    /**
     * 敏感词查询列表
     * @param sensitiveDto
     * @return
     */
    @PostMapping("/list")
    public ResponseResult list(@RequestBody AdSensitiveDto sensitiveDto){
    log.info("接收到参数：{}",sensitiveDto);
        return adSensitiveService.pageQuery(sensitiveDto);
    }

    /**
     * 敏感词新增
     * @param wmSensitive
     * @return
     */
    @PostMapping("/save")
    public ResponseResult save(@RequestBody WmSensitive wmSensitive){
        log.info("接收到新增参数：{}",wmSensitive);
        return adSensitiveService.saveSensitive(wmSensitive);
    }

    /**
     * 敏感词修改
     * @param sensitiveDto
     * @return
     */
    @PostMapping("/update")
    public ResponseResult update(@RequestBody AdSensitiveDto sensitiveDto){
        log.info("接收到修改参数：{}",sensitiveDto);
        return adSensitiveService.updateSensitive(sensitiveDto);
    }

    /**
     * 敏感词删除
     * @param id
     * @return
     */
    @DeleteMapping("del/{id}")
    public ResponseResult del(@PathVariable Integer id){
        log.info("接收到删除参数:{}",id);
        return adSensitiveService.del(id);
    }
}
